import Mock from 'mockjs'
const { datalist1 } = Mock.mock({
  datalist1: [
    {
      timesTamp: '@date(2022-06-20 10:25:00)',
      totalField: '@float(49180.98,49190.50,94,50)',
      magneticAngle: '@float(1.39,1.40,3,4)',
      magneticInclination: '@float(42.50,43.90,94,50)',
      northboundComponent: '@float(36238.98,36240.50,94,50)',
      verticalComponents: '@float(36238.98,36240.50,94,50)',
      sastorientedComponent: '@float(-890.98,-888.50,94,50)'
    },
    {
      timesTamp: '@date(2022-06-20 10:26:00)',
      totalField: '@float(49180.98,49190.50,94,50)',
      magneticAngle: '@float(1.39,1.40,3,4)',
      magneticInclination: '@float(42.50,43.90,94,50)',
      northboundComponent: '@float(36238.98,36240.50,94,50)',
      verticalComponents: '@float(36238.98,36240.50,94,50)',
      sastorientedComponent: '@float(-890.98,-888.50,94,50)'
    },
    {
      timesTamp: '@date(2022-06-20 10:27:00)',
      totalField: '@float(49180.98,49190.50,94,50)',
      magneticAngle: '@float(1.39,1.40,3,4)',
      magneticInclination: '@float(42.50,43.90,94,50)',
      northboundComponent: '@float(36238.98,36240.50,94,50)',
      verticalComponents: '@float(36238.98,36240.50,94,50)',
      sastorientedComponent: '@float(-890.98,-888.50,94,50)'
    },
    {
      timesTamp: '@date(2022-06-20 10:28:00)',
      totalField: '@float(49180.98,49190.50,94,50)',
      magneticAngle: '@float(1.39,1.40,3,4)',
      magneticInclination: '@float(42.50,43.90,94,50)',
      northboundComponent: '@float(36238.98,36240.50,94,50)',
      verticalComponents: '@float(36238.98,36240.50,94,50)',
      sastorientedComponent: '@float(-890.98,-888.50,94,50)'
    },
    {
      timesTamp: '@date(2022-06-20 10:29:00)',
      totalField: '@float(49180.98,49190.50,94,50)',
      magneticAngle: '@float(1.39,1.40,3,4)',
      magneticInclination: '@float(42.50,43.90,94,50)',
      northboundComponent: '@float(36238.98,36240.50,94,50)',
      verticalComponents: '@float(36238.98,36240.50,94,50)',
      sastorientedComponent: '@float(-890.98,-888.50,94,50)'
    },
    {
      timesTamp: '@date(2022-06-20 10:30:00)',
      totalField: '@float(49180.98,49190.50,94,50)',
      magneticAngle: '@float(1.39,1.40,3,4)',
      magneticInclination: '@float(42.50,43.90,94,50)',
      northboundComponent: '@float(36238.98,36240.50,94,50)',
      verticalComponents: '@float(36238.98,36240.50,94,50)',
      sastorientedComponent: '@float(-890.98,-888.50,94,50)'
    }
  ]
})

const { datalist2 } = Mock.mock({
  datalist2: [
    {
      timesTamp: '@date(2022-06-19 08:25:00)',
      totalField: '@float(49180.98,49190.50,94,50)',
      magneticAngle: '@float(1.39,1.40,3,4)',
      magneticInclination: '@float(42.50,43.90,94,50)',
      northboundComponent: '@float(36238.98,36240.50,94,50)',
      verticalComponents: '@float(36238.98,36240.50,94,50)',
      sastorientedComponent: '@float(-890.98,-888.50,94,50)'
    },
    {
      timesTamp: '@date(2022-06-19 08:26:00)',
      totalField: '@float(49180.98,49190.50,94,50)',
      magneticAngle: '@float(1.39,1.40,3,4)',
      magneticInclination: '@float(42.50,43.90,94,50)',
      northboundComponent: '@float(36238.98,36240.50,94,50)',
      verticalComponents: '@float(36238.98,36240.50,94,50)',
      sastorientedComponent: '@float(-890.98,-888.50,94,50)'
    },
    {
      timesTamp: '@date(2022-06-19 08:27:00)',
      totalField: '@float(49180.98,49190.50,94,50)',
      magneticAngle: '@float(1.39,1.40,3,4)',
      magneticInclination: '@float(42.50,43.90,94,50)',
      northboundComponent: '@float(36238.98,36240.50,94,50)',
      verticalComponents: '@float(36238.98,36240.50,94,50)',
      sastorientedComponent: '@float(-890.98,-888.50,94,50)'
    },
    {
      timesTamp: '@date(2022-06-19 08:28:00)',
      totalField: '@float(49180.98,49190.50,94,50)',
      magneticAngle: '@float(1.39,1.40,3,4)',
      magneticInclination: '@float(42.50,43.90,94,50)',
      northboundComponent: '@float(36238.98,36240.50,94,50)',
      verticalComponents: '@float(36238.98,36240.50,94,50)',
      sastorientedComponent: '@float(-890.98,-888.50,94,50)'
    },
    {
      timesTamp: '@date(2022-06-19 08:29:00)',
      totalField: '@float(49180.98,49190.50,94,50)',
      magneticAngle: '@float(1.39,1.40,3,4)',
      magneticInclination: '@float(42.50,43.90,94,50)',
      northboundComponent: '@float(36238.98,36240.50,94,50)',
      verticalComponents: '@float(36238.98,36240.50,94,50)',
      sastorientedComponent: '@float(-890.98,-888.50,94,50)'
    },
    {
      timesTamp: '@date(2022-06-19 08:30:00)',
      totalField: '@float(49180.98,49190.50,94,50)',
      magneticAngle: '@float(1.39,1.40,3,4)',
      magneticInclination: '@float(42.50,43.90,94,50)',
      northboundComponent: '@float(36238.98,36240.50,94,50)',
      verticalComponents: '@float(36238.98,36240.50,94,50)',
      sastorientedComponent: '@float(-890.98,-888.50,94,50)'
    }
  ]
})

export default {
  findData: (config) => {
    // 采用解构赋值
    let { startDate, endDate } = JSON.parse(config.body)
    // console.log(startDate)
    // console.log(endDate)
    if (startDate === '2022-06-20 00:00:00' && endDate === '2022-06-20 23:59:59') {
      return {
        code: 200,
        msg: '获取数据成功',
        data: datalist1
      }
    } else if (startDate === '2022-06-19 00:00:00' && endDate === '2022-06-19 23:59:59') {
      return {
        code: 200,
        msg: '获取数据成功',
        data: datalist2
      }
    } else {
      return {
        code: 200, //假设状态码正确，只是为了显示数据，不然应该是5xx，服务器请求报错
        msg: '获取数据失败,显示6.20数据',
        data: datalist1
      }
    }
  }
}
